package com.ruoyi.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.TbTransfer;
import com.ruoyi.system.service.ITbTransferService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 【请填写功能名称】Controller
 * 
 * @author ruoyi
 * @date 2022-03-19
 */
@RestController
@RequestMapping("/system/transfer")
public class TbTransferController extends BaseController
{
    @Autowired
    private ITbTransferService tbTransferService;


    @GetMapping("/list")
    public TableDataInfo list(TbTransfer tbTransfer)
    {
        startPage();
        List<TbTransfer> list = tbTransferService.selectTbTransferList(tbTransfer);
        return getDataTable(list);
    }

    @PostMapping("/export")
    public void export(HttpServletResponse response, TbTransfer tbTransfer)
    {
        List<TbTransfer> list = tbTransferService.selectTbTransferList(tbTransfer);
        ExcelUtil<TbTransfer> util = new ExcelUtil<TbTransfer>(TbTransfer.class);
        util.exportExcel(response, list, "【请填写功能名称】数据");
    }


    @GetMapping(value = "/{transferId}")
    public AjaxResult getInfo(@PathVariable("transferId") Long transferId)
    {
        return AjaxResult.success(tbTransferService.selectTbTransferByTransferId(transferId));
    }


    @PostMapping
    public AjaxResult add(@RequestBody TbTransfer tbTransfer)
    {
        return toAjax(tbTransferService.insertTbTransfer(tbTransfer));
    }


    @PutMapping
    public AjaxResult edit(@RequestBody TbTransfer tbTransfer)
    {
        return toAjax(tbTransferService.updateTbTransfer(tbTransfer));
    }

	@DeleteMapping("/{transferIds}")
    public AjaxResult remove(@PathVariable Long[] transferIds)
    {
        return toAjax(tbTransferService.deleteTbTransferByTransferIds(transferIds));
    }
}
